package com.study.spmongodb.effective.java;

import java.util.concurrent.TimeUnit;

/**
 * @author MI
 * @version 1.0
 * @date 2020/10/30 16:03
 */
public class StopThread {

    private static Boolean stopRequested = Boolean.FALSE;

    public static void main(String[] args) throws InterruptedException {
        final Thread backThread = new Thread(() -> {
            int i = 0;
            if (!stopRequested)
                while (true) {
                    i++;
                }
        });

        backThread.start();
        TimeUnit.SECONDS.sleep(1);
        stopRequested = true;

    }
}
